package input;

public class Key {
	private boolean lastState = false;
	private boolean currentState = false;
	private boolean nextState = false;
	
	public void update() {
		lastState = currentState;
		currentState = nextState;
	}
	
	public void toogle(boolean newState) {
		this.nextState = newState;
	}
	
	
	/**
	 * If the key was false and now true (clicada)
	 * @return
	 */
	public boolean wasPressed() {
		return !lastState && currentState;
	}
	/**
	 * If the key is pressed (it may had been clicked or being held).
	 * @return
	 */
	public boolean isPressed() {
		return currentState;
	}
	/**
	 * IF the key was released (solta)
	 * @return
	 */
	public boolean wasReleased() {
		return lastState && !currentState;
	}
}
